package org.ali.structuralpattern.adapterpattern;

import org.ali.structuralpattern.adapterpattern.adapter.SDCardAdapter1;
import org.ali.structuralpattern.adapterpattern.adapter.SDCardAdapter2;
import org.ali.structuralpattern.adapterpattern.adapter.SDCardAdapter3;
import org.ali.structuralpattern.adapterpattern.disk.UDisk;

/**
 * 适配器模式
 */
public class Main {
    public static void main(String[] args) {
        Computer computer = new Computer();

        UDisk uDisk = new UDisk();
        computer.readHardDisk(uDisk);

        SDCardAdapter1 SDCardAdapter1 = new SDCardAdapter1();
        computer.readHardDisk(SDCardAdapter1);

        SDCardAdapter2 SDCardAdapter2 = new SDCardAdapter2();
        computer.readHardDisk(SDCardAdapter2);

        SDCardAdapter3 sdCardAdapter3 = new SDCardAdapter3() {
            @Override
            public void read() {
                readSDCard();
            }
        };
        computer.readHardDisk(sdCardAdapter3);
    }
}
